package com.github.dongglin.smart.spring.boot.plus.common.exception;

import com.github.dongglin.smart.spring.boot.plus.common.enums.BusinessCode;
import lombok.Getter;

/**
 * Service 通用异常类
 *
 * @author gengjiaping
 * @date 2021-8-13
 **/
@Getter
public class QueryNotFoundException extends RuntimeException {

    private static final long serialVersionUID = -2000022807238016991L;

    private String code;

    protected Object data;

    /**
     * 构造函数
     */
    public QueryNotFoundException() {
        super("查询对象不存在");
    }

    /**
     * 信息
     *
     * @param msg
     */
    public QueryNotFoundException(final String msg) {
        super(msg);
    }


    /**
     * 信息
     *
     * @param msg
     */
    public QueryNotFoundException(String code, final String msg) {
        super(msg);
        this.code = code;
    }


    /**
     * @param msg   信息
     * @param cause 原因
     */
    public QueryNotFoundException(final String msg, final Throwable cause) {
        super(msg, cause);
    }

    /**
     * 服务异常
     *
     * @param businessCode businessCode
     */
    public QueryNotFoundException(final BusinessCode businessCode) {
        super(businessCode.getMsg());
        this.code = businessCode.getCode();
    }

    /**
     * @param businessCode businessCode
     * @param data         data
     */
    public QueryNotFoundException(final BusinessCode businessCode, Object data) {
        super(businessCode.getMsg());
        this.code = businessCode.getCode();
        this.data = data;
    }
}
